package com.triones.api.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.api.entity.vo.*;
import com.triones.api.service.FaitWalletService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * api - 法定货币相关接口
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/fiat")
public class ApiFiatController extends BaseController {

    private final FaitWalletService faitWalletService;

    /**
     * 法定货币钱包列表
     */
    @GetMapping(value = "/wallet/list")
    public R<List<FaitWalletVO>> apiWalletList() {
        return R.ok(faitWalletService.apiWalletList());
    }

    /**
     * 法定货币钱包详情
     * @return
     */
    @GetMapping("/walletDetail")
    public R<FaitWalletVO> walletDetail(@NotBlank(message = "币种不能为空") String ccy) {
        return R.ok(faitWalletService.walletDetail(ccy));
    }

    /**
     * 子账户交易列表（分页）
     * txnType: （auth：消费、exchange：提现、atm_withdrawals:取现、不传默认查询所有）
     */
    @GetMapping(value = "/trade/pageList")
    public TableDataInfo<CustomEcWalletBillVO> apiTradePageList(@NotBlank(message = "币种不能为空") String ccy, String txnType, PageQuery pageQuery) {
        return faitWalletService.apiTradePageList(ccy,pageQuery,txnType);
    }

    /**
     * 子账户交易详情
     */
    @GetMapping(value = "/trade/detail/{id}")
    public R<EcWalletBillVO> apiTradeDetail(@NotNull(message = "交易id不能为空") @PathVariable Long id) {
        return R.ok(faitWalletService.apiTradeDetail(id));
    }
}
